/**
 * Created by zzy on 2017/9/27.
 */
import {observer} from "mobx-react";
import {observable, action, computed, observe} from 'mobx'
import NetRequestLuo from '../util/NetRequest'
import loginStore from "../store/LoginStoreLuo";

class ShoppingCartStore{
    @observable _selectCount=0;
    @observable list=[];

    constructor(){
        this.getShoppingCart();
    }
    @action setShoppingCart(cartList){
        this.list=cartList;
    }

    @computed get selectCount(){
        return this._selectCount;
    }

    @action  async getShoppingCart(){
        let hasLogin = await loginStore.loginState();
        if (hasLogin) {
                let param={};
                NetRequestLuo.selectedProductList(param).then((data)=>{
                    LOG('购物车----------'+JSON.stringify(data));
                    this.list=data;
                    this._selectCount=data.allSelectCount
                })

        };
    }
    @computed get shoppingCart(){
        return this.list;
    }
}
let shoppingCartStore=new ShoppingCartStore();
export default shoppingCartStore
